import axiosServer from '../utils/request'
import axios from 'axios'
/**
 * 商品列表
 * @returns 
 */
export const RequestProductList = (pageNo=1,pageSize=10)=>{
    return axiosServer({
        method:'get',
        url:'/api/shop/list',
        params:{
            pageNo,
            pageSize
        }
    })
}


/**
 * 商品分类
 * @returns 
 */
 export const RequestCategoryList = ()=>{
    return axiosServer({
        method:'get',
        url:'/api/shop/category/list',
    })
}

/**
 * 查找分类商品
 */
export const RequestProductListByCategoryId = (categoryId:number)=>{
    return axiosServer({
        method:'get',
        url:'/api/shop/list/category',
        params:{
            categoryId
        }
    })
}

/**
 * 查找分类商品，7,8,9
 */
 export const RequestProductListByCategoryId1=(categoryId:number)=>{
    return axios({
        method:'get',
        url:'/category/list'
    })
}

/**
 * 添加商品
 * @returns 
 */
 export const RequestAddProduct = (product)=>{
    return axiosServer({
        method:'post',
        url:'/api/shop/add',
        data:{
            categoryId:product.categoryId,
            product:product.productname,
            picture:product.picture,
            shop:product.shop,
            price:product.price,
            oldprice:product.oldPrice,
            putaway:product.putaway
        }
    })
}




/**
 * 删除商品
 */
export const RequestDeleteProduct =(id:number)=>{
    return axiosServer({
        method:'get',
        url:'/api/shop/delete',
        params:{
            id
        }
    })
}

/**
 * 修改商品
 */
 export const RequestUpdateProduct = (product)=>{
    return axiosServer({
        method:'post',
        url:'/api/shop/update',
        data:{
            id:product.id,
            categoryId:product.categoryId,
            product:product.productname,
            picture:product.picture,
            shop:product.shop,
            price:product.price,
            oldprice:product.oldPrice,
            putaway:product.putaway
        }
    })
}

/**
 * 商品详情
 */
export const RequestProductDetailById = (id:number)=>{
    return axiosServer({
        method:'get',
        url:'/api/shop/find',
        params:{
            id
        }
    })
}
